import 'package:applications/module/home/bean/application_bean.dart';
import 'package:applications/utils/image_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 最受欢迎App 单元格布局
class RecommendItem extends StatelessWidget {
  final int index;
  final Entry model;
  const RecommendItem({
    Key? key,
    required this.index,
    required this.model,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 20.w),
      constraints: BoxConstraints(
        maxWidth: (ScreenUtil().screenWidth - 30.w) / 3.5,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          ClipRRect(
            borderRadius: BorderRadius.circular(36.w),
            child: AspectRatio(
              aspectRatio: 3.0 / 3.0,
              child: loadNetworkImage(model.imImage?.last.label ?? ""),
            ),
          ),
          SizedBox(height: 10.h),
          Center(
            child: Text(
              model.imName?.label ?? "--",
              maxLines: 1,
              textAlign: TextAlign.center,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                fontSize: 30.sp,
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
          Center(
            child: Text(
              model.category?.attributes?.label ?? "",
              maxLines: 1,
              textAlign: TextAlign.center,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(color: Colors.grey, fontSize: 28.sp),
            ),
          ),
        ],
      ),
    );
  }
}
